//
//  CZTitleView.swift
//  微博08
//
//  Created by apple on 16/2/29.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class CZTitleView: UIButton {
    
    init(title: String) {
        super.init(frame: CGRectZero)
        
        self.setTitle(title, forState: UIControlState.Normal)
        self.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        self.setImage(UIImage(named: "navigationbar_arrow_down"), forState: UIControlState.Normal)
        self.sizeToFit()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        
        // 标题和图片换位置
        // 1.设置标题origin.x = 0
        titleLabel?.frame.origin.x = 0
        
        // 2.设置图片的origin.x = 标题的右边
        imageView?.frame.origin.x = titleLabel!.frame.width + 3
    }
}
